/*
 * 结束日期设置
 */
var year = new Date().getFullYear() ;
var month = new Date().getMonth()+1;
var day = new Date().getDate();
var yemoday = '{"type":"date","beginYear":1910,"endYear":'+year+',"endMonth":'+month+',"endDay":'+day+'}';
var bemoday = '{"type":"hour","beginYear":'+year+',"beginMonth":'+month+',"beginDay":'+day+',"customData":{"h":[{"text":"上午","value":"上午"},{"text":"下午","value":"下午"}]}}';
$("#birthday").attr('data-options',yemoday);
$("#offlineTime").attr('data-options',bemoday);


(function($) {
//				$.init();
	var birthday = $('#birthday')[0];
	var btns = $('input[name="birthday"]');
	btns.each(function(i, btn) {
		btn.addEventListener('tap', function() {
			var optionsJson = this.getAttribute('data-options') || '{}';
			var options = JSON.parse(optionsJson);
			var picker = new $.DtPicker(options);
			document.activeElement.blur();//关闭软键盘
			picker.show(function(rs) {
				birthday.value = rs.text;
				picker.dispose();
			});
		}, false);
	});
	//=============出生日期================================
	
	var offlineTime = $('#offlineTime')[0];
	var btns2 = $('input[name="offlineTime"]');
	btns2.each(function(i, btn) {
		btn.addEventListener('tap', function() {
			
			var optionsJson = this.getAttribute('data-options') || '{}';
			var options = JSON.parse(optionsJson);
			var picker = new $.DtPicker(options);    //在外面没有设置$是mui的时候直接写mui
			document.activeElement.blur();//关闭软键盘
			picker.show(function(rs) {
               	offlineTime.value = rs.text;
		        //return false;    //这是阻止对话框关闭的
	          	picker.dispose();  //释放组件资源，释放后将将不能再操作组件.所以每次用完便立即调用 dispose 进行释放，下次用时再创建新实例
			});
			
		}, false);
	});
	//=============预约门诊就诊时间================================
	
	var hzTime = $('#hzTime')[0];
	var btns3 = $('input[name="hzTime"]');
	btns3.each(function(i, btn) {
		btn.addEventListener('tap', function() {
			
			var optionsJson = this.getAttribute('data-options') || '{}';
			var options = JSON.parse(optionsJson);
			var picker = new $.DtPicker(options);    //在外面没有设置$是mui的时候直接写mui
			document.activeElement.blur();//关闭软键盘
			picker.show(function(rs) {
               	hzTime.value = rs.text;
               	hzTime.style.color = '#000';

		        //return false;    //这是阻止对话框关闭的
	          	picker.dispose();  //释放组件资源，释放后将将不能再操作组件.所以每次用完便立即调用 dispose 进行释放，下次用时再创建新实例
			});
			
		}, false);
	});
	//=============会诊时间================================
	
})(mui);